#include <iostream>
#include "vectorfunctions.h"
void sortbetween(int x[], int start, int finish)
{
	int i, j, aux;
	for(i=1; i<finish; ++i){
		aux=x[i];
		j=i-1;
		while (aux<x[j] && j>start){
			x[j+1]=x[j];
			--j;
		}
		x[j+1]=aux;
	}
			
}

int main()
{
	int l, pmax, pmin, start, finish;
	int a[100];
	cout<<"Length of array a : ";
	cin>>l;
	readVector(a, l);
	pmin = minofVector(a, l);
	pmax = maxofVector(a, l);
	if(pmin>pmax){
		start=pmax;
		finish=pmin;
	}
	else {
		start=pmin;
		finish=pmax;
	}
	sortbetween(a, start, finish);	
	printVector(a, l);
return 0;
}

